<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <title>管理界面</title>
    <style>
        table {
            text-align: center;
        }

        th {
            background: #66ccff;
        }
    </style>
</head>

<body>
    <?php
    require_once "admin_fns.php";
    if (!check_admin()) {
        exit('您不是管理员，无法访问此页面！');
    }
    ?>
    <h2>管理界面</h2>
    <hr>
    <h3>用户管理</h3>
    <table border="1" cellspacing="1">
        <tr>
            <th width="50px">ID</th>
            <th width="150px">用户名</th>
            <th width="50px">性别</th>
            <th width="120px">生日</th>
            <th width="120px">电话</th>
            <th width="120px">QQ</th>
            <th width="200px">邮箱</th>
            <th width="100px">管理员</th>
            <th width="100px">所有商铺</th>
            <th width="100px">操作</th>
        </tr>
        <?php
        require_once('db_fns.php');
        $conn = db_connect();
        $sql = "select * from user";
        $result = $conn->query($sql);
        while ($row = $result->fetch_array()) {
        ?>
            <tr>
                <td><?php echo $row['uid']; ?></td>
                <td><?php echo $row['sno']; ?></td>
                <td><?php echo $row['sex']; ?></td>
                <td><?php echo $row['birthday']; ?></td>
                <td><?php echo $row['tel']; ?></td>
                <td><?php echo $row['qq']; ?></td>
                <td><?php echo $row['email']; ?></td>
                <td><?php echo $row['admin']; ?></td>
                <td><?php echo $row['mid']; ?></td>
                <td><a href="">编辑</a>&nbsp;&nbsp;<a href="admin_delete_user.php?uid=<?php echo $row['uid']; ?>">删除</a></td>
            </tr>
        <?php
        }
        ?>
    </table>
    <br>
    <hr>
    <h3>商家管理</h3>
    <table border="1" cellspacing="1">
        <tr>
            <th width="50px">ID</th>
            <th width="200px">商家名</th>
            <th width="800px">商家介绍</th>
            <th width="50px">状态</th>
            <th width="80px">推荐系数</th>
            <th width="50px">调整</th>
            <th width="100px">操作</th>
        </tr>
        <?php
        $sql = "select * from merchant";
        $result = $conn->query($sql);
        while ($row = $result->fetch_array()) {
        ?>
            <tr>
                <td><?php echo $row['mid']; ?></td>
                <td><?php echo $row['name']; ?></td>
                <td><?php echo $row['introduction']; ?></td>
                <td><?php echo $row['frozen'] == 'Y' ? '冻结' : '正常'; ?></td>
                <td><?php echo $row['priority']; ?></td>
                <td><a href="admin_change_priority.php?op=1&mid=<?php echo $row['mid']; ?>" style="text-decoration: none;">+</a> / <a href="admin_change_priority.php?op=0&mid=<?php echo $row['mid']; ?>" style="text-decoration: none;">-</a></td>
                <td><a href="admin_change_frozen.php?mid=<?php echo $row['mid']; ?>"><?php echo $row['frozen'] == 'Y' ? '解冻' : '冻结' ?></a></td>
            </tr>
        <?php
        }
        ?>
    </table>
    <hr>
    <br>
    <a href="admin_dishes.php">菜品管理</a>
    <br>
    <a href="admin_order.php">订单管理</a>
    <br>
    <a href="user_center.php">返回首页</a>
</body>

</html>